<template>
  <div class="app-container">
    <div class="Search">
      <!--工具条-->
      <el-col :span="24" class="toolbar" style="padding-bottom: 0px;">
        <el-form :inline="true" :model="query">
          <el-form-item v-has="'PLATFROM_TENANT_QUERY'">
            <el-cascader ref="tenantTree" placeholder="所属租户" :props="tenantProps" :options="tenantOptions"
              @change="selectTenant" clearable collapse-tags filterable></el-cascader>
          </el-form-item>
          <el-form-item>
            <el-cascader ref="organTree" placeholder="所属组织" :props="props" :options="organOptions" @change="selectOrgan"
              collapse-tags clearable filterable></el-cascader>
          </el-form-item>
          <el-form-item>
            <el-cascader ref="goodsTypeTree" placeholder="商品分类" :props="goodsTypeTreeProps"
              :options="goodsTypeTreeOptions" @change="selectGoodsType" filterable></el-cascader>
          </el-form-item>
          <el-form-item>
            <el-input v-model="query.params.goodsName" placeholder="商品名称" clearable />
          </el-form-item>
          <el-form-item>
            <el-cascader ref="supplierTree" placeholder="供应商" :props="supplierProps" :options="supplierOptions"
              @change="selectSupplier" clearable collapse-tags filterable></el-cascader>
          </el-form-item>
          <el-form-item>
            <el-input v-model="query.params.goodsDescribe" placeholder="商品描述" clearable />
          </el-form-item>
          <el-form-item>
            <el-input v-model="query.params.productionPlace" placeholder="商品产地" clearable />
          </el-form-item>
          <el-form-item>
            <el-button v-has="'GOODS_LIST'" type="primary" icon="el-icon-search" size="mini"
              @click="fetchData">查询</el-button>
          </el-form-item>
          <el-form-item>
            <el-button v-has="'GOODS_ADD'" type="success" icon="el-icon-plus" size="mini"
              @click="handleAdd">新增</el-button>
          </el-form-item>
          <el-form-item>
            <el-button v-has="'GOODS_ADD'" type="success" icon="el-icon-plus" size="mini"
              @click="handleLaunchGoodses">发布商品</el-button>
          </el-form-item>
        </el-form>
      </el-col>
    </div>
    <div class="block">
      <el-table v-loading="listLoading" :data="list" element-loading-text="Loading"
        @selection-change="handleSelectionChange" border fit highlight-current-row>
        <el-table-column type="selection" width="45">
        </el-table-column>
        <el-table-column align="center" label="序号" width="95">
          <template slot-scope="scope">
            {{ scope.$index }}
          </template>
        </el-table-column>
        <el-table-column label="所属机构" width="110" prop="organId" :formatter="translateOrgan" />
        <el-table-column label="商品分类" width="110">
          <template slot-scope="scope">
            {{ scope.row.goodsTypeId }}
          </template>
        </el-table-column>
        <el-table-column label="商品名称" width="110">
          <template slot-scope="scope">
            {{ scope.row.goodsName }}
          </template>
        </el-table-column>
        <el-table-column label="供应商" width="110">
          <template slot-scope="scope">
            {{ scope.row.supplierId }}
          </template>
        </el-table-column>
        <el-table-column label="商品图片url" width="110">
          <template slot-scope="scope">
            <el-image style="width: 100px; height: 100px" :src="scope.row.goodsImg">
            </el-image>
          </template>
        </el-table-column>
        <el-table-column label="商品描述" width="110">
          <template slot-scope="scope">
            {{ scope.row.goodsDescribe }}
          </template>
        </el-table-column>
        <el-table-column label="商品规格单位" width="110">
          <template slot-scope="scope">
            {{ scope.row.unit }}
          </template>
        </el-table-column>
        <el-table-column label="商品规格值" width="110">
          <template slot-scope="scope">
            {{ scope.row.unitValue }}
          </template>
        </el-table-column>
        <el-table-column label="商品产地" width="110">
          <template slot-scope="scope">
            {{ scope.row.productionPlace }}
          </template>
        </el-table-column>
        <el-table-column label="备注" width="110">
          <template slot-scope="scope">
            {{ scope.row.remark }}
          </template>
        </el-table-column>
        <el-table-column fixed="right" align="center" prop="created_at" label="操作" width="200">
          <template slot-scope="scope">
            <el-link v-has="'GOODS_EDIT'" icon="el-icon-edit" type="warning" style="cursor: pointer;"
              @click="handleEdit(scope.$index, scope.row)">
              修改
            </el-link>
            <el-link v-has="'GOODS_REMOVE'" icon="el-icon-delete" type="danger"
              @click="handleDelete(scope.$index, scope.row)">
              删除
            </el-link>
            <el-link v-has="'GOODS_IMG_EDIT'" icon="el-icon-picture-outline-round" type="success"
              @click="handleGoodsImgAdd(scope.$index, scope.row)">
              添加图片
            </el-link>
            <el-link v-has="'SHOW_GOODS_IMG_BY_GOODS'" type="info" icon="el-icon-picture"
              @click="handleGetGoodsImgs(scope.$index, scope.row)">
              查看图片
            </el-link>
            <el-link v-has="'GOODS_PRICE_EDIT'" icon="el-icon-money" type="success"
              @click="handleAddGoodsPrice(scope.$index, scope.row)">
              添加定价
            </el-link>
            <el-link v-has="'GOODS_PRICE_LIST'" icon="el-icon-coin" type="info"
              @click="handleShowGoodsPriceList(scope.$index, scope.row)">
              查看定价情况
            </el-link>
            <el-link v-has="'handleAssignToOrgan'" icon="el-icon-coin" type="info"
              @click="handleAssignToOrgan(scope.$index, scope.row)">
              分配给组织
            </el-link>
          </template>
        </el-table-column>
      </el-table>
    </div>
    <div class="Search">
      <!--工具条-->
      <el-col :span="14" class="toolbar" style="padding-bottom: 0px;">
        <el-form :inline="true" :model="query">
          <el-form-item>
            <el-link v-has="'GOODS_ADD'" type="warning" size="mini" icon="el-icon-sell"
              @click="handleManageStatus(32)">上架</el-link>
          </el-form-item>
          <el-form-item>
            <el-link v-has="'GOODS_ADD'" type="danger" icon="el-icon-sold-out" size="mini"
              @click="handleManageStatus(64)">下架</el-link>
          </el-form-item>
        </el-form>
      </el-col>
      <el-col :span="8" class="toolbar" style="padding-bottom: 0px;">
        <div class="block">
          <el-pagination :current-page="currentPage" :page-sizes="[10, 20, 30, 40]" :page-size="pageSize"
            layout="total, sizes, prev, pager, next, jumper" :total="total" @size-change="handleSizeChange"
            @current-change="handleCurrentChange" />
        </div>
      </el-col>
    </div>


    <div class="block">
      <!--弹框-->
      <el-dialog :title="titleMap[dialogStatus]" :visible.sync="dialogFormGoodsImgAddVisible">
        <el-form :model="form">
          <el-form-item v-if="addForGoodsImgVisible" label="主键">
            <el-input v-model="goodsImg.id" placeholder="主键" disabled auto-complete="off" />
          </el-form-item>
          <el-form-item label="关联商品">
            <el-input disabled v-model="goodsImg.goodsId" placeholder="关联商品" auto-complete="off" />
          </el-form-item>
          <el-form-item label="图片所在地址">
            <el-upload class="upload-demo" action="/api/file.allService/admin/FileService/uploadFile"
              :headers="uploadHeader" :with-credentials="true" :on-preview="handlePreview" :on-remove="handleRemove"
              :before-remove="beforeRemove" multiple :data='fileUloadParams' :on-success="uploadImageOnSuccess"
              name="file" :limit="1" :on-exceed="handleExceed" :file-list="fileList">
              <el-button size="small" type="primary">点击上传</el-button>
              <div slot="tip" class="el-upload__tip">只能上传jpg/png文件，且不超过500kb</div>
            </el-upload>
          </el-form-item>
          <el-form-item label="图片类型">
            <el-select v-model="goodsImg.imgType" placeholder="图片类型" style="width: 100%">
              <el-option v-for="item in query.googsImgTypeOptions" :key="item.value" :label="item.label"
                :value="item.value">
              </el-option>
            </el-select>
          </el-form-item>
          <el-form-item label="目录">
            <el-input v-model="goodsImg.folder" placeholder="目录" auto-complete="off" />
          </el-form-item>
          <el-form-item label="排序">
            <el-select v-model="goodsImg.sort" placeholder="排序" style="width: 100%">
              <el-option v-for="item in query.options" :key="item.value" :label="item.label" :value="item.value">
              </el-option>
            </el-select>
          </el-form-item>
          <el-table-column label="所属组织" width="110" prop="organId" :formatter="translateOrgan" />
          <el-form-item label="组织路径">
            <el-input v-model="goodsImg.organPath" placeholder="组织路径" auto-complete="off" />
          </el-form-item>
          <el-form-item label="备注">
            <el-input v-model="goodsImg.remark" placeholder="备注" auto-complete="off" />
          </el-form-item>
        </el-form>
        <div slot="footer" class="dialog-footer">
          <el-button @click="dialogFormGoodsImgAddVisible = false">取 消</el-button>
          <el-button type="primary" @click="handleGoodsImgEditSave">确 定</el-button>
        </div>
      </el-dialog>
    </div>
    <div class="block">
      <!--弹框-->
      <el-dialog :title="'查看商品价格'" width="88%" :visible.sync="dialogShowGoodsPriceListAddVisible">
        <div class="block">
          <el-form :inline="true" :model="query">
            <el-form-item>
              <el-button v-has="'GOODS_ADD'" type="success" icon="el-icon-plus" size="mini"
                @click="handleAddGoodsPrice">新增</el-button>
            </el-form-item>
          </el-form>
          <el-table v-loading="listLoading" :data="goodsPriceList" element-loading-text="Loading" border fit
            highlight-current-row>
            <el-table-column align="center" label="序号" width="50">
              <template slot-scope="scope">
                {{ scope.$index }}
              </template>
            </el-table-column>
            <el-table-column label="所属组织" width="110" prop="organId" :formatter="translateOrgan" />
            <el-table-column label="关联商品" width="110">
              <template slot-scope="scope">
                {{ scope.row.goodsId }}
              </template>
            </el-table-column>
            <el-table-column label="商品名称" width="110">
              <template slot-scope="scope">
                {{ scope.row.goodsName }}
              </template>
            </el-table-column>
            <el-table-column label="商品编码" width="110">
              <template slot-scope="scope">
                {{ scope.row.goodsCode }}
              </template>
            </el-table-column>
            <el-table-column label="价格(单位：分)" width="110">
              <template slot-scope="scope">
                {{ scope.row.price }}
              </template>
            </el-table-column>
            <el-table-column label="商品成本(单位：分)" width="110">
              <template slot-scope="scope">
                {{ scope.row.costPrice }}
              </template>
            </el-table-column>
            <el-table-column label="折扣价格(单位：分)" width="110">
              <template slot-scope="scope">
                {{ scope.row.discountPrice }}
              </template>
            </el-table-column>
            <el-table-column label="建议价格(单位：分)" width="110">
              <template slot-scope="scope">
                {{ scope.row.suggestedRetailPrice }}
              </template>
            </el-table-column>
            <el-table-column label="备注" width="110">
              <template slot-scope="scope">
                {{ scope.row.remark }}
              </template>
            </el-table-column>
            <el-table-column fixed="right" align="center" prop="created_at" label="操作">
              <template slot-scope="scope">
                <el-link type="primary" style="cursor: pointer;" icon="edit"
                  @click="handleModifyGoodsPrice(scope.$index, scope.row)">
                  修改
                </el-link>
                <el-link v-if="!scope.row.isSet" type="danger" icon="delete" style="cursor: pointer;"
                  @click="handleDeleteGoodsPrice(scope.$index, scope.row)">
                  删除
                </el-link>
                <el-link v-has="'DICTIONARYORGAN_ASSIGNEDDICTIONARY'" type="info" style="cursor: pointer;"
                  @click="handleBindGoodsSpecification(scope.$index, scope.row)">
                  绑定商品规格
                </el-link>
              </template>
            </el-table-column>
          </el-table>
        </div>
        <div class="block">
          <el-pagination :current-page="query.goodsPrice.currentPage" :page-sizes="[10, 20, 30, 40]"
            :page-size="query.goodsPrice.pageSize" layout="total, sizes, prev, pager, next, jumper"
            :total="query.goodsPrice.total" @size-change="handleGoodsPriceSizeChange"
            @current-change="handleGoodsPriceCurrentChange" />
        </div>
        <div slot="footer" class="dialog-footer">
          <el-button @click="dialogShowGoodsPriceListAddVisible = false">取 消</el-button>
          <el-button type="primary" @click="handleGoodsImgEditSave">确 定</el-button>
        </div>
      </el-dialog>
    </div>
    <div class="block">
      <!--弹框-->
      <el-dialog :title="titleMap[dialogStatus]" :visible.sync="dialogFormVisible">

        <el-form :model="form" :rules="goodsRule" ref="goodsForm">
          <el-form-item v-if="addForVisible" label="商品id" ref="">
            <el-input v-model="form.id" placeholder="商品id" disabled auto-complete="off" />
          </el-form-item>
          <el-form-item v-has="'PLATFROM_TENANT_QUERY'" prop="tenantId" label="所属租户" placeholder="所属租户" required>
            <el-cascader v-model="form.tenantId" ref="tenantTreeForm" placeholder="所属租户" :props="tenantProps"
              :options="tenantOptions" @change="chooseTenantForm" style="width:100%" clearable collapse-tags
              filterable></el-cascader>
          </el-form-item>
          <el-form-item required prop="organId" label="所属组织">
            <el-cascader v-model="form.organId" ref="organTreeForm" placeholder="所属组织" :props="props"
              :options="organFormOptions" @change="chooseOrganForm" style="width:100%" collapse-tags
              filterable></el-cascader>
          </el-form-item>
          <el-form-item required prop="goodsName" label="商品名称">
            <el-input v-model="form.goodsName" placeholder="商品名称" auto-complete="off" />
          </el-form-item>
          <el-form-item required prop="goodsTypeId" label="商品分类">
            <el-cascader v-model="form.goodsTypeId" ref="goodsTypeTreeForm" style="width:100%" placeholder="商品分类"
              :props="goodsTypeTreeProps" :options="goodsTypeTreeOptions" @change="getGoodsType(form)" collapse-tags
              filterable></el-cascader>
          </el-form-item>
          <el-form-item required prop="supplierId" label="供应商">
            <el-cascader v-model="form.supplierId" ref="applyerTree" style="width:100%" placeholder="商品分类" :props="props"
              :options="supplierOptions" @change="getSupplier" collapse-tags filterable></el-cascader>
          </el-form-item>
          <el-form-item required prop="goodsImg" label="商品图片url">
            <el-upload class="upload-demo" action="/api/file.allService/admin/FileService/uploadFile"
              :headers="uploadHeader" :with-credentials="true" :on-preview="handlePreview" :on-remove="handleRemove"
              :before-remove="beforeRemove" multiple :data='fileUloadParams' :on-success="uploadFileOnSuccess" name="file"
              :limit="1" :on-exceed="handleExceed" :file-list="fileList">
              <el-button size="small" type="primary">点击上传</el-button>
              <div slot="tip" class="el-upload__tip">只能上传jpg/png文件，且不超过500kb</div>
            </el-upload>
          </el-form-item>
          <el-form-item required prop="productionPlace" label="商品产地">
            <el-input v-model="form.productionPlace" placeholder="商品产地" auto-complete="off" />
          </el-form-item>
          <el-form-item required prop="goodsDescribe" label="商品描述">
            <el-input v-model="form.goodsDescribe" placeholder="商品描述" auto-complete="off" />
          </el-form-item>
          <el-form-item required prop="measurementType" label="商品计量类型">
            <el-select v-model="form.measurementType" style="width:100%" @change="handleInitMeasurementUnitOptions(form)"
              placeholder="请选择商品计量单位">
              <el-option v-for="item in query.measurementTypeOptions" :key="item.value" :label="item.label"
                :value="item.value">
              </el-option>
            </el-select>
          </el-form-item>
          <el-form-item required prop="unitValue" label="商品数量">
            <el-input v-model="form.unitValue" placeholder="商品数量" auto-complete="off" />
          </el-form-item>
          <el-form-item required prop="unit" label="商品计量单位">
            <el-select v-model="form.unit" style="width:100%" placeholder="商品计量单位">
              <el-option v-for="item in query.measurementUnitOptions" :key="item.value" :label="item.label"
                :value="item.value">
              </el-option>
            </el-select>
          </el-form-item>
          <el-form-item label="备注">
            <el-input v-model="form.remark" placeholder="备注" auto-complete="off" />
          </el-form-item>
        </el-form>
        <div slot="footer" class="dialog-footer">
          <el-button @click="dialogFormVisible = false">取 消</el-button>
          <el-button type="primary" @click="handleEditSave">确 定</el-button>
        </div>
      </el-dialog>
    </div>
    <div class="block">
      <!--弹框-->
      <el-dialog :title="titleMap[dialogStatus]" :visible.sync="dialogForGoodsImgVisible">
        <div class="demo-image__lazy">
          <el-image v-for="url in goodsImgUrls" :key="url" :src="url" lazy></el-image>
        </div>
      </el-dialog>
    </div>
    <div class="block">
      <!--弹框-->
      <el-dialog :title="'添加商品SKU【商品售价】'" :visible.sync="dialogFormGoodsPriceVisible">
        <el-form :model="goodsPrice" :rules="goodsPriceRule" ref="goodsPriceForm">
          <el-form-item v-if="addForGoodsPriceVisible" label="SKU编码">
            <el-input v-model="goodsPrice.id" disabled placeholder="SKU编码" auto-complete="off" />
          </el-form-item>
          <el-form-item label="关联商品" required prop="goodsId">
            <el-input disabled v-model="goodsPrice.goodsId" placeholder="关联商品" auto-complete="off" />
          </el-form-item>
          <el-form-item v-has="'PLATFROM_TENANT_QUERY'" label="所属租户" required prop="tenantId">
            <el-cascader v-model="goodsPrice.tenantId" ref="tenantTreeForm" placeholder="所属租户" :props="tenantProps"
              :options="tenantOptions" @change="chooseTenant(goodsPrice)" style="width:100%" clearable collapse-tags
              filterable></el-cascader>
          </el-form-item>
          <el-form-item label="所属组织" required prop="organId">
            <el-cascader v-model="goodsPrice.organId" ref="organTreeForm" placeholder="所属组织" :props="props"
              :options="organFormOptions" @change="chooseOrganForm" style="width:100%" collapse-tags
              filterable></el-cascader>
          </el-form-item>
          <el-form-item label="商品名称" required prop="goodsName">
            <el-input v-model="goodsPrice.goodsName" placeholder="SKU名称" auto-complete="off" />
          </el-form-item>
          <el-form-item label="销售域" required prop="isVending">
            <el-radio v-model="goodsPrice.isVending" label="0" border>商铺</el-radio>
            <el-radio v-model="goodsPrice.isVending" label="1" border>售卖机</el-radio>
          </el-form-item>
          <el-form-item label="商品分类" required prop="goodsTypeId">
            <el-cascader v-model="goodsPrice.goodsTypeId" ref="goodsTypeTreeForm" style="width:100%" placeholder="商品分类"
              :props="goodsTypeTreeProps" :options="goodsTypeTreeOptions" @change="getGoodsType(goodsPrice)" collapse-tags
              filterable></el-cascader>
          </el-form-item>
          <el-form-item label="商品编码" required prop="goodsCode">
            <el-input v-model="goodsPrice.goodsCode" placeholder="SKU编码" auto-complete="off" />
          </el-form-item>
          <el-form-item label="价格(单位：分)" required prop="price">
            <el-input v-model="goodsPrice.price" placeholder="价格(单位：分)" auto-complete="off" />
          </el-form-item>
          <el-form-item label="折扣价格(单位：分)" required prop="discountPrice">
            <el-input v-model="goodsPrice.discountPrice" placeholder="价格(单位：分)" auto-complete="off" />
          </el-form-item>
          <el-form-item label="商品成本(单位：分)" required prop="costPrice">
            <el-input v-model="goodsPrice.costPrice" placeholder="价格(单位：分)" auto-complete="off" />
          </el-form-item>
          <el-form-item label="建议价格(单位：分)" required prop="suggestedRetailPrice">
            <el-input v-model="goodsPrice.suggestedRetailPrice" placeholder="价格(单位：分)" auto-complete="off" />
          </el-form-item>
          <el-form-item label="商品计量类型" required prop="measurementType">
            <el-select v-model="goodsPrice.measurementType" style="width:100%"
              @change="handleInitMeasurementUnitOptions(goodsPrice)" placeholder="请选择商品计量单位">
              <el-option v-for="item in query.measurementTypeOptions" :key="item.value" :label="item.label"
                :value="item.value">
              </el-option>
            </el-select>
          </el-form-item>
          <el-form-item label="SKU库存数" required prop="stockCount">
            <el-input v-model="goodsPrice.stockCount" placeholder="SKU库存数" auto-complete="off" />
          </el-form-item>
          <el-form-item label="SKU计量单位" required prop="unit">
            <el-select v-model="goodsPrice.unit" style="width:100%" placeholder="SKU计量单位">
              <el-option v-for="item in query.measurementUnitOptions" :key="item.value" :label="item.label"
                :value="item.value">
              </el-option>
            </el-select>
          </el-form-item>

          <el-form-item label="备注">
            <el-input v-model="goodsPrice.remark" placeholder="备注" auto-complete="off" />
          </el-form-item>
        </el-form>
        <div slot="footer" class="dialog-footer">
          <el-button @click="dialogFormGoodsPriceVisible = false">取 消</el-button>
          <el-button type="primary" @click="handleAddGoodsPriceSave">确 定</el-button>
        </div>
      </el-dialog>
    </div>
    <div class="block">
      <!--弹框-->
      <el-dialog :title="titleMap[dialogStatus]" :visible.sync="dialogFormOrganVisible">
        <el-tree ref="assigneeTree" :data="organTree" :default-expand-all="true" :props="organTreeProps"
          :check-strictly="false" show-checkbox node-key="id" highlight-current />
        <div slot="footer" class="dialog-footer">
          <el-button @click="dialogFormOrganVisible = false">取 消</el-button>
          <el-button type="primary" @click="getCheckedNodes">确 定</el-button>
        </div>
      </el-dialog>
    </div>


    <div class="block">
      <!--弹框-->
      <el-dialog :title="'商品分类规格选择'" width="78%" :visible.sync="dialogFormShowGoodsSpecificationVisible">
        <div class="Search">
          <!--工具条-->
          <el-col :span="24" class="toolbar" style="padding-bottom: 0px;">
            <el-form :inline="true" :model="query">
              <el-form-item label="规格名称">
                <el-input v-model="query.goodsSpecification.parameterName" placeholder="规格名称" auto-complete="off" />
              </el-form-item>
              <el-form-item label="规格组">
                <el-cascader ref="specificationGroupTree" placeholder="规格组" :props="specificationGroupTreeProps"
                  :options="specificationGroupOptions" @change="selectSpecificationGroup" filterable></el-cascader>
              </el-form-item>
              <el-form-item>
                <el-button type="primary" @click="handleQueryGoodsTypeSpecification">查询</el-button>
              </el-form-item>
            </el-form>
          </el-col>
        </div>
        <el-table v-loading="listLoading" :data="goodsSpecificationList"
          @selection-change="handleGoodsSpecifiactionSelectionChange" element-loading-text="Loading" border fit
          highlight-current-row>
          <el-table-column type="selection" width="40" />
          <el-table-column align="center" label="序号" width="45">
            <template slot-scope="scope">
              {{ scope.$index }}
            </template>
          </el-table-column>
          <el-table-column label="规格名称" width="110">
            <template slot-scope="scope">
              {{ scope.row.parameterName }}
            </template>
          </el-table-column>

          <el-table-column label="显示区域" width="110">
            <template slot-scope="scope">
              {{ scope.row.displayArea }}
            </template>
          </el-table-column>
          <el-table-column label="商品分类编号" width="110">
            <template slot-scope="scope">
              {{ scope.row.goodsTypeId }}
            </template>
          </el-table-column>
          <el-table-column label="规格组编号" width="110">
            <template slot-scope="scope">
              {{ scope.row.groupId }}
            </template>
          </el-table-column>
          <el-table-column label="备注" width="110">
            <template slot-scope="scope">
              {{ scope.row.remark }}
            </template>
          </el-table-column>
          <el-table-column>
            <template slot-scope="scope">
              <el-link v-has="'DICTIONARYORGAN_ASSIGNEDDICTIONARY'" type="success" style="cursor: pointer;"
                @click="handleShowGoodsSpecificationItem(scope.$index, scope.row)">
                查看规格值
              </el-link>
            </template>
          </el-table-column>

        </el-table>
        <div class="block">
          <el-pagination :current-page="query.goodsSpecification.currentPage" :page-sizes="[10, 20, 30, 40]"
            :page-size="query.goodsSpecification.pageSize" layout="total, sizes, prev, pager, next, jumper"
            :total="query.goodsSpecification.total" @size-change="handleQueryGoodsSpecificationSizeChange"
            @current-change="handleQueryGoodsSpecificationCurrentChange" />
        </div>
        <div slot="footer" class="dialog-footer">
          <el-button @click="dialogFormShowGoodsSpecificationVisible = false">取 消</el-button>
          <el-button type="primary" @click="handleGoodsSpecificationToSPU">确 定</el-button>
        </div>
      </el-dialog>
    </div>

    <div class="block">
      <el-drawer title="商品发布" size="65%" :visible.sync="drawer" :direction="direction" :before-close="handleClose">
        <div class="app-container">

          <el-steps :active="step" align-center>
            <el-step title="选择类目"></el-step>
            <el-step title="填写信息"></el-step>
            <el-step title="提交信息"></el-step>
          </el-steps>

          <el-form label-position="top" :model="form" :rules="goodsRule" ref="goodsForm">

            <div class="block" style="margin: 10px 0 10px 0;" v-show="step == 1">
              <el-form-item required prop="goodsTypeId" label="请选择您要使用的类目:">
                <el-cascader v-model="form.goodsTypeId" ref="goodsTypeTreeForm" style="width: 320px;" placeholder="商品类目"
                  :props="goodsTypeTreeProps" :options="goodsTypeTreeOptions" @change="getGoodsType(form)" collapse-tags
                  filterable></el-cascader>
              </el-form-item>
              <el-link type="primary" @click="handleNextStep">我己知晓规则，现在发布商品</el-link>
            </div>

            <div class="block" v-show="step == 2">
              <el-form-item v-has="'PLATFROM_TENANT_QUERY'" prop="tenantId" label="所属租户" placeholder="所属租户" required>
                <el-cascader v-model="form.tenantId" ref="tenantTreeForm" placeholder="所属租户" :props="tenantProps"
                  :options="tenantOptions" @change="chooseTenantForm" style="width:100%" clearable collapse-tags
                  filterable></el-cascader>
              </el-form-item>
              <el-form-item required prop="organId" label="所属组织">
                <el-cascader v-model="form.organId" ref="organTreeForm" placeholder="所属组织" :props="props"
                  :options="organFormOptions" @change="chooseOrganForm" style="width:100%" collapse-tags
                  filterable></el-cascader>
              </el-form-item>
              <el-form-item required prop="goodsName" label="商品名称">
                <el-input v-model="form.goodsName" placeholder="商品名称" auto-complete="off" />
              </el-form-item>
              <el-form-item required prop="goodsCode" label="商品编码">
                <el-input v-model="form.goodsCode" placeholder="商品编码" auto-complete="off" />
              </el-form-item>
              <el-form-item required prop="preSaler" label="是否预售商品">
                <el-radio-group v-model="form.preSaler">
                  <el-radio label="1">预售商品</el-radio>
                  <el-radio label="0">非预售商品</el-radio>
                </el-radio-group>
              </el-form-item>
              <el-form-item label="商铺编号">
                <el-select v-model="form.storeId" clearable placeholder="请选择商铺编号" @change="chooseStore"
                  style="width:100%">
                  <el-option v-for="item in storeList" :key="item.value" :label="item.storeName" :value="item.id">
                  </el-option>
                </el-select>
              </el-form-item>
              <el-form-item required prop="salesDomain" label="销售域">
                <el-radio-group v-model="form.salesDomain">
                  <el-radio label="1">线上</el-radio>
                  <el-radio label="2">门店</el-radio>
                </el-radio-group>
              </el-form-item>

              <el-form-item required prop="supplierId" label="供应商">
                <el-cascader v-model="form.supplierId" ref="applyerTree" style="width:100%" placeholder="商品分类"
                  :props="props" :options="supplierOptions" @change="getSupplier" collapse-tags filterable></el-cascader>
              </el-form-item>
              <el-form-item required prop="freightType" label="配送类型">
                <el-radio-group v-model="form.freightType">
                  <el-radio label="1">快递</el-radio>
                  <el-radio label="2">同城配送</el-radio>
                  <el-radio label="3">门店自提</el-radio>
                </el-radio-group>
              </el-form-item>


              <el-form-item required prop="brandId" label="品牌">
                <el-cascader ref="goodsTypeBrandTree" placeholder="品牌" style="width:100%" :props="goodsTypeBrandProps"
                  :options="goodsTypeBrandOptions" @change="selectGoodsTypeBrand(form)" filterable></el-cascader>
              </el-form-item>

              <el-card class="box-card" style="margin: 10px 0 0 0;" shadow="hover">
                <div slot="header" class="clearfix">
                  <span>销售属性选择:</span> <span style="font-size: x-small;">请至少选择一个属性</span>
                  <el-button style="float: right;" type="primary" icon="el-icon-edit" round
                    @click="handleShowQueryGoodsTypeProps">添加属性选择项</el-button>
                </div>
                <div class="text item">
                  <el-form ref="form" :model="form" :inline="false" label-width="80px">
                    <el-form-item v-for="goodsTypeProps in chooseGoodsTypePropsNodes" :label="goodsTypeProps.propName">
                      <el-checkbox-group @change="handleGoodsTypePropsChange" v-model="skuPropsSpecifications.props">
                        <el-checkbox v-for="goodsTypePropsValue in goodsTypeProps.goodsTypePropValues"
                          :label="goodsTypePropsValue.id" :name="goodsTypePropsValue.id">{{
                            goodsTypePropsValue.goodsPropsValue }}</el-checkbox>
                      </el-checkbox-group>
                    </el-form-item>
                  </el-form>
                </div>
              </el-card>

              <el-card class="box-card" style="margin: 10px 0 0 0;" shadow="hover">
                <div slot="header" class="clearfix">
                  <span>规格选择</span>
                  <el-button style="float: right;" type="primary" icon="el-icon-edit" round
                    @click="handleShowGoodsSpecification">添加规格选择项</el-button>
                </div>
                <div class="text item">
                  <el-form ref="form" :model="form" :inline="false" label-width="80px">
                    <el-form-item v-for="specification in chooseSpecificationNodes" :label="specification.parameterName">
                      <el-checkbox-group @change="handleGoodsSpecificationItemChange"
                        v-model="skuPropsSpecifications.specifications">
                        <el-checkbox v-for="specificationItem in specification.specificationItems"
                          :label="specificationItem.id" :name="specificationItem.id">{{
                            specificationItem.specificationValue }}</el-checkbox>
                      </el-checkbox-group>
                    </el-form-item>
                  </el-form>
                </div>

              </el-card>

              <el-card class="box-card" style="margin: 10px 0 0 0;" shadow="hover">
                <div slot="header" class="clearfix">
                  <span>主图信息</span>

                </div>
                <div class="text item">
                  <div style="float:left;">
                    <el-form-item label="主图">
                      <el-upload action="/api/file.allService/admin/FileService/uploadFile" list-type="picture-card"
                        :on-remove="handleRemove" :headers="uploadHeader" :with-credentials="true"
                        :on-preview="handlePreview" :before-remove="beforeRemove" multiple :data='fileUloadParams'
                        :on-success="uploadFileOnSuccess" name="file" :limit="1" :on-exceed="handleExceed"
                        :file-list="fileList">
                        <i class="el-icon-plus"></i>
                      </el-upload>
                      <el-dialog :visible.sync="dialogVisible">
                        <img width="100%" :src="form.image" alt="">
                      </el-dialog>
                    </el-form-item>

                    <el-form-item label="图片">
                      <el-upload action="/api/file.allService/admin/FileService/uploadFile" list-type="picture-card"
                        :on-remove="handleRemove" :headers="uploadHeader" :with-credentials="true"
                        :on-preview="handlePreview" :before-remove="beforeRemove" multiple :data='fileUloadParams'
                        :on-success="uploadImageOnSuccess" name="file" :limit="4" :on-exceed="handleExceed"
                        :file-list="imageList">
                        <i class="el-icon-plus"></i>
                      </el-upload>
                      <el-dialog :visible.sync="dialogVisible">
                        <img width="100%" :src="form.image" alt="">
                      </el-dialog>
                    </el-form-item>
                  </div>
                </div>
              </el-card>


              <el-card class="box-card" style="margin: 10px 0 0 0;" shadow="hover">
                <div slot="header" class="clearfix">
                  <span>商品说明</span>
                </div>
                <div class="text item">
                  <el-form-item>
                    <Tinymce ref="editor" v-model="form.goodsDescribe" :height="400" />
                  </el-form-item>
                </div>
              </el-card>

              <el-card class="box-card" style="margin: 10px 0 0 0;" shadow="hover">
                <div slot="header" class="clearfix">
                  <span>包装信息</span>

                </div>
                <div class="text item">
                  <el-form-item label="商品毛重">
                    <el-input v-model="goodsExt.grossWeight" placeholder="商品毛重（千克）"></el-input>
                  </el-form-item>
                  <el-form-item label="商品净重">
                    <el-input v-model="goodsExt.netWeight" placeholder="商品净重（千克）"></el-input>
                  </el-form-item>
                  <el-form-item label="商品尺寸">
                    <el-input v-model="goodsExt.length" style="width:33%" placeholder="长（厘米）"></el-input>
                    <el-input v-model="goodsExt.width" style="width:33%" placeholder="宽（厘米）"></el-input>
                    <el-input v-model="goodsExt.height" style="width:32%" placeholder="高（厘米）"></el-input>
                  </el-form-item>
                  <el-form-item label="包装尺寸">
                    <el-input v-model="goodsExt.packLength" style="width:33%" placeholder="长（厘米）"></el-input>
                    <el-input v-model="goodsExt.packWidth" style="width:33%" placeholder="宽（厘米）"></el-input>
                    <el-input v-model="goodsExt.packHeight" style="width:32%" placeholder="高（厘米）"></el-input>
                  </el-form-item>
                  <el-form-item label="包装清单">
                    <el-input v-model="goodsExt.packageInfo" placeholder="包装清单"></el-input>
                  </el-form-item>
                </div>
              </el-card>


              <el-card class="box-card" style="margin: 10px 0 0 0;" shadow="hover">
                <div slot="header" class="clearfix">
                  <span>物流信息</span>
                </div>
                <div class="text item">
                  <el-form-item lable="运费模板">
                    <el-cascader ref="freightTemplateTree" placeholder="运费模板" :props="freightTemplateProps"
                      :options="freightTemplateOptions" @change="selectFreightTemplate(form)" filterable></el-cascader>
                  </el-form-item>
                </div>

              </el-card>

              <div class="bottom clearfix">
                <el-button style="float: right; margin: 0 0 0 10px;" type="primary"
                  @click="handleBuildSPU">下一步</el-button>
              </div>
            </div>
          </el-form>
        </div>
      </el-drawer>
    </div>

    <div class="block">
      <!--弹框-->
      <el-dialog :title="'商品分类属性选择'" width="78%" :visible.sync="dialogFormShowGoodsPropsVisible">
        <div class="Search">

          <!--工具条-->
          <el-col :span="24" class="toolbar" style="padding-bottom: 0px;">
            <el-form :inline="true" :model="query">
              <el-form-item label="属性名称">
                <el-input v-model="query.goodsTypeProps.propName" placeholder="属性名称" auto-complete="off" />
              </el-form-item>
              <el-form-item>
                <el-button type="primary" @click="handleQueryGoodsTypePropsPage">查询</el-button>
              </el-form-item>
            </el-form>
          </el-col>


        </div>
        <div class="block">
          <el-table v-loading="listLoading" :data="goodsTypePropsList" @selection-change="handleGoodsPropSelectionChange"
            element-loading-text="Loading" border fit highlight-current-row>
            <el-table-column type="selection" width="40" />
            <el-table-column align="center" label="序号" width="45">
              <template slot-scope="scope">
                {{ scope.$index }}
              </template>
            </el-table-column>

            <el-table-column label="分类属性名称" width="110">
              <template slot-scope="scope">
                {{ scope.row.propName }}
              </template>
            </el-table-column>
            <el-table-column label="是否必选" width="110">
              <template slot-scope="scope">
                {{ scope.row.isMust ? '必选' : '非必选' }}
              </template>
            </el-table-column>
            <el-table-column label="关联商品分类" width="110">
              <template slot-scope="scope">
                {{ scope.row.goodsTypeId }}
              </template>
            </el-table-column>
            <el-table-column label="所属组织" width="110">
              <template slot-scope="scope">
                {{ scope.row.organId }}
              </template>
            </el-table-column>
            <el-table-column label="组织路径" width="110">
              <template slot-scope="scope">
                {{ scope.row.organPath }}
              </template>
            </el-table-column>
            <el-table-column label="备注" width="110">
              <template slot-scope="scope">
                {{ scope.row.remark }}
              </template>
            </el-table-column>
          </el-table>
          <div class="block">
            <el-pagination :current-page="currentPage" :page-sizes="[10, 20, 30, 40]" :page-size="pageSize"
              layout="total, sizes, prev, pager, next, jumper" :total="total" @size-change="handleSizeChange"
              @current-change="handleCurrentChange" />
          </div>
        </div>
        <div slot="footer" class="dialog-footer">
          <el-button @click="dialogFormShowGoodsPropsVisible = false">取 消</el-button>
          <el-button type="primary" @click="handleGoodsTypePropsToSPU">确 定</el-button>
        </div>
      </el-dialog>
    </div>

  </div>
</template>
<script>
import { getList, doDelete, doEdit, doLanuch, assign2Organs, queryGoodsAssignee as queryAlreadyAssignedOrgans, doManage as manageStatus } from '@/api/Goods/'
import { doEdit as doUploadImg, getList as getGoodsImgs, getGoodsImgByGoods } from '@/api/GoodsImg/'
import { queryAssigneeOrgan, querySubordinateOrgan } from '@/api/Organ'
import { getGoodsTypeTree } from '@/api/GoodsType'
import { getList as getGoodsPriceList, doDelete as deleteGoodsPrice, doEdit as saveGoodsPrice } from '@/api/GoodsPrice/'
import { getDictionaryGroup } from '@/api/dictionary'
import { queryForList as queryGoodsTypeBrand } from '@/api/GoodsTypeBrand/'
import { getStoreList } from '@/api/Store/'
import { queryForList as queryFreightTemplate } from '@/api/FreightTemplate/'
import { queryForList as querySpecificationGroupList } from '@/api/goodsSpecificationGroup'
import { getList as queryGoodsTypeSpecification } from '@/api/GoodsSpecification/'
import { getList as queryGoodsTypeSpecificationItem, queryForList as queryGoodsSpecificationItemForList } from '@/api/GoodsSpecificationItem/'
import { queryForList as queryGoodsTypePropsForList, getList as queryGoodsTypePropsPage } from '@/api/goodsTypeProps'
import { queryForList as queryGoodsTypePropsValueForList } from '@/api/goodsTypePropsValue/'
import { getOrganId, getTenantId, getOrganPath, getCurrentLoginUserId, handleBuildTreeDataStruct, getSuperManagerId, getSelectedNodes, getSelectedNodesObject, getSystemErrorCode, getCurrentTimeYYYY_MM_dd_HH_mm_ss } from '@/api/utils'
import { getTenantList, getToken, getOrganList, getDictionary, translateOrganId2OrganName } from '@/utils/auth'
import Tinymce from '@/components/Tinymce'
import Sticky from '@/components/Sticky'

import localStorageUtil from '@/utils/localStorageUtil'
import sessionStorageUtil from '@/utils/sessionStorageUtil'

export default {
  name: 'goodsPage',
  components: { Tinymce, Sticky },
  data() {
    return {
      list: [],
      listLoading: true,
      total: 5,
      currentPage: 1,
      pageSize: 10,
      dialogFormVisible: false,
      addForVisible: false,
      drawer: false,
      direction: 'rtl',
      fileList: [],
      imageList: [],
      storeList: [],
      storeMap: null,
      selectionsToOnline: [],
      fileUloadParams: { organId: 1, createBy: 1 },
      dialogFormGoodsImgAddVisible: false,
      addForGoodsImgVisible: false,
      dialogForGoodsImgVisible: false,
      dialogFormGoodsPriceVisible: false,
      addForGoodsPriceVisible: false,
      dialogShowGoodsPriceListAddVisible: false,
      dialogFormOrganVisible: false,
      dialogFormShowGoodsSpecificationVisible: false,
      dialogFormShowGoodsPropsVisible: false,
      goodsImgUrls: [],
      goodsPriceList: [],
      organList: [],
      goodsSpecificationList: [],
      chooseSpecificationNodes: [],
      organTree: [],
      chooseGoodsTypePropsNodes: [],
      goodsTypePropsList: [],
      skuPropsSpecifications: {
        props: [],
        specifications: []
      },
      imageMap: {

      },

      dialogVisible: false,
      step: 1,
      form: {
        id: '',
        organId: '',
        organPath: '',
        organName: '',
        goodsTypeId: '',
        goodsTypePath: '',
        goodsName: '',
        supplierId: '',
        goodsImg: '',
        goodsDescribe: '',
        unit: '',
        unitValue: '',
        productionPlace: '',
        sys: '',
        isDeleted: '',
        quote: '',
        createBy: '',
        createDate: '',
        updateBy: '',
        updateDate: '',
        measurementType: '',
        remark: '',
        goodsImgs: [],
        goodsExt: null,
        goodsLinkPropses: [],
        goodsLinkPropsValues: [],
        goodsLinkSpecifications: [],
        goodsLinkSpecificationItems: [],
        assignee: {
          id: '',
          organPath: ''
        }
      },
      goodsImg: {
        id: '',
        goodsId: '',
        imgUrl: '',
        imgType: '',
        folder: '',
        sort: '',
        organId: '',
        organPath: '',
        createBy: '',
        createDate: '',
        updateBy: '',
        updateDate: '',
        isDeleted: '',
        remark: ''
      },
      goodsExt: {
        createBy: '',
        createDate: '',
        features: '',
        goodsId: '',
        grossWeight: '',
        height: '',
        id: '',
        isDeleted: '',
        length: '',
        netWeight: '',
        organId: '',
        organPath: '',
        packHeight: '',
        packLength: '',
        packWidth: '',
        packageInfo: '',
        parentId: '',
        remark: '',
        status: '',
        tenantId: '',
        updateBy: '',
        updateDate: '',
        width: ''
      },
      goodsPrice: {
        id: '',
        goodsId: '',
        goodsName: '',
        goodsCode: '',
        organId: '',
        organPath: '',
        isDeleted: '',
        isVending: false,
        createBy: '',
        createDate: '',
        updateBy: '',
        updateDate: '',
        remark: '',
        price: '',
        costPrice: '',
        discountPrice: '',
        suggestedRetailPrice: ''
      },
      goodsSpecification: {
        id: '',
        groupId: '',
        displayArea: '',
        parameterName: '',
        goodsTypeId: '',
        organId: '',
        organPath: '',
        isDeleted: '',
        createBy: '',
        createDate: '',
        updateBy: '',
        updateDate: '',
        remark: ''
      },
      assign2Organs: {
        assignees: [],
        id: '',
        createBy: '',
        updateBy: ''
      },
      // 新增or编辑弹框标题(根据点击的新增or编辑按钮显示不同的标题)
      titleMap: {
        add: '新增',
        edit: '编辑',
        addGoodsImg: '添加商品图片',
        showGoodsImgs: '商品图片',
        assignOrgan: '选择需要指派的组织'
      },
      isClearable: true, // 可清空（可选）
      isAccordion: true, // 可收起（可选）
      valueId: null, // 初始ID（可选）
      organFormOptions: [],
      tenantOptions: [],
      organOptions: [{ id: '1', parentId: '2', organName: '平台', children: [] }],
      supplierOptions: [{ id: '1', parentId: '2', organName: '平台', children: [] }],
      specificationGroupOptions: [{ id: '1', parentId: '2', typeName: '请选择规格组', children: [] }],
      goodsTypeBrandOptions: [],
      goodsTypeBrandProps: {
        children: 'children',
        label: 'brandName',
        value: 'id',
        multiple: false,
        checkStrictly: true,
        emitPath: false
      },
      freightTemplateOptions: [],
      organTreeProps: {
        children: 'children',
        label: 'organName',
        url: 'url'
      },
      freightTemplateProps: { // 配置项（必选）
        value: 'id',
        label: 'name',
        children: 'children',
        checkStrictly: true,
        title: '物流模板',
        multiple: false,
        checkStrictly: true,
        emitPath: false
        // disabled:true
      },
      props: { // 配置项（必选）
        value: 'id',
        label: 'organName',
        children: 'children',
        title: '组织',
        multiple: false,
        checkStrictly: true,
        emitPath: false
        // disabled:true
      },
      organTreeProps: {
        children: 'children',
        label: 'organName',
        url: 'url'
      },
      tenantProps: { // 配置项（必选）
        value: 'id',
        label: 'organName',
        children: 'children',
        title: '租户',
        multiple: false,
        checkStrictly: true,
        emitPath: false
        // disabled:true
      },
      specificationGroupTreeProps: { // 配置项（必选）
        value: 'id',
        label: 'name',
        children: 'children',
        checkStrictly: true,
        title: '规格组'
        // disabled:true
      },
      supplierProps: { // 配置项（必选）
        value: 'id',
        label: 'organName',
        children: 'children',
        title: '租户',
        multiple: false,
        checkStrictly: true,
        emitPath: false
        // disabled:true
      },
      goodsTypeTreeProps: { // 配置项（必选）
        value: 'id',
        label: 'typeName',
        children: 'children',
        checkStrictly: true,
        title: '组织'
        // disabled:true
      },
      organQueryModel: 'selfAndSub',
      supplier: null, //供应商
      goodsType: null, //商品分类
      // // 新增or编辑弹框标题(根据点击的新增or编辑按钮显示不同的标题)
      optionData: [{ id: '1', parentId: '2', organName: '平台', children: [] }],
      clearable: true, // 可清空（可选）
      accordion: true, // 可收起（可选）
      goodsTypeValueId: null, // 初始ID（可选）

      goodsAssignees: {
        assignees: []
      },
      // // 新增or编辑弹框标题(根据点击的新增or编辑按钮显示不同的标题)
      dialogStatus: '',
      goodsTypeTreeOptions: [{ id: '1', parentId: '2', typeName: '平台', children: [] }],
      query: {
        params: {
          id: '',
          organId: '',
          organPath: '',
          organName: '',
          goodsTypeId: '',
          goodsTypePath: '',
          goodsName: '',
          supplierId: '',
          goodsImg: '',
          goodsDescribe: '',
          unit: '',
          unitValue: '',
          productionPlace: '',
          sys: '',
          isDeleted: '',
          quote: '',
          createBy: '',
          createDate: '',
          updateBy: '',
          updateDate: '',
          remark: '',
          assignee: { organPath: '' },
          organIds: []
        },
        goodsPrice: {
          goodsId: '',
          organId: '',
          organPath: '',
          tenantId: '',
          total: 5,
          currentPage: 1,
          pageSize: 10
        },
        goodsSpecificationGroup: {
          id: '',
          name: '',
          organId: '',
          organIds: [],
          organPath: '',
          tenantId: '',
          isDeleted: '',
          createBy: '',
          createDate: '',
          updateBy: '',
          updateDate: '',
          remark: ''
        },
        goodsSpecification: {
          id: '',
          groupId: '',
          displayArea: '',
          parameterName: '',
          goodsTypeId: '',
          organId: '',
          tenantId: '',
          organPath: '',
          isDeleted: '',
          createBy: '',
          createDate: '',
          updateBy: '',
          updateDate: '',
          remark: '',
          total: 5,
          currentPage: 1,
          pageSize: 10
        },
        goodsSpecificationItem: {
          specificationId: '',
          total: 5,
          currentPage: 1,
          pageSize: 10
        },
        goodsTypeProps: {
          id: '',
          goodsTypeId: '',
          goodsTypePath: '',
          propName: '',
          propCode: '',
          organId: '',
          organPath: '',
          isDeleted: '',
          createBy: '',
          createDate: '',
          updateBy: '',
          updateDate: '',
          remark: '',
          isMust: null,
          isMutilSelect: null,
          isNav: null,
          total: 5,
          currentPage: 1,
          pageSize: 10,
        },
        goodsTypePropsItem: {
          id: '',
          goodsPropsId: '',
          goodsPropsValue: '',
          goodsPropsIds: [],
          organId: '',
          organPath: '',
          isDeleted: '',
          createBy: '',
          createDate: '',
          updateBy: '',
          updateDate: '',
          remark: '',
          total: 5,
          currentPage: 1,
          pageSize: 10,
        },
        store: {
          addressId: '', // 关联地址
          enable: '', // 是否生效
          id: '', // 主键
          organId: '', // 所属组织
          organPath: '', // 组织路径
          storeName: '', // 店铺名称
          total: 0,
          pageSize: 10,
          currentPage: 1
        },
        goodsImg: {
          organPath: '',
          organId: '',
          goodsId: '',
          tenantId: ''
        },
        organParams: {
          organPath: ''
        },
        goodsTypesOrganQuery: {
          goodsTypeId: ''
        },
        goodsOrganQuery: {
          id: '',
          organId: '',
          tenantId: ''
        },
        organ: {
          organPath: '',
          organId: '',
          organName: '',
          pageSize: 10,
          total: 0,
          currentPage: 1
        },
        timeValue: '',
        options: [{
          value: '1',
          label: '黄金糕'
        }, {
          value: '2',
          label: '双皮奶'
        }],
        googsImgTypeOptions: [],
        measurementTypeOptions: [],
        measurementUnitOptions: [],
        value: ''
      },
      goodsRule: {
        organId: [
          { required: true, message: '请选择合适的组织机构', trigger: 'change' }
        ],
        tenantId: [
          { required: true, message: '请选择租户', trigger: 'change' }
        ],
        organPath: [{ required: true, message: '请选择合适的组织机构', trigger: 'change' }],
        unitValue: [{ required: true, message: '请填写商品数量', trigger: 'change' }],
        measurementType: [{ required: true, message: '请选择计量类型', trigger: 'change' }],
        goodsTypeId: [{ required: true, message: '请选择商品类型', trigger: 'change' }],
        goodsName: [{ required: true, message: '请输入商品折扣价', trigger: 'change' }],
        supplierId: [{ required: true, message: '请输入商品建议价', trigger: 'change' }],
        goodsImg: [{ required: true, message: '请上传商品主图片', trigger: 'change' }],
        productionPlace: [{ required: true, message: '请填写商品产地', trigger: 'change' }],
        goodsDescribe: [{ required: true, message: '请填写商品描述', trigger: 'change' }],
        unit: [{ required: true, message: '请填写商品计量单位', trigger: 'change' }]
      },
      goodsPriceRule: {
        organId: [
          { required: true, message: '请选择合适的组织机构', trigger: 'change' }
        ],
        tenantId: [
          { required: true, message: '请选择租户', trigger: 'change' }
        ],
        organPath: [{ required: true, message: '请选择合适的组织机构', trigger: 'change' }],
        unitValue: [{ required: true, message: '请填写商品数量', trigger: 'change' }],
        measurementType: [{ required: true, message: '请选择计量类型', trigger: 'change' }],
        goodsTypeId: [{ required: true, message: '请选择商品类型', trigger: 'change' }],
        goodsName: [{ required: true, message: '请输入商品折扣价', trigger: 'change' }],
        supplierId: [{ required: true, message: '请输入商品建议价', trigger: 'change' }],
        goodsImg: [{ required: true, message: '请上传商品主图片', trigger: 'change' }],
        productionPlace: [{ required: true, message: '请填写商品产地', trigger: 'change' }],
        goodsDescribe: [{ required: true, message: '请填写商品描述', trigger: 'change' }],
        unit: [{ required: true, message: '请填写商品计量单位', trigger: 'change' }],
        stockCount: [{ required: true, message: '请填写商品库存', trigger: 'change' }]
      }

    }
  },
  computed: {
    uploadHeader() {
      return {
        'Authorization': getToken(),
        'OrganId': getOrganId(),
        'tenantId': getTenantId(),
        'userId': getCurrentLoginUserId()
      }
    }
  }

  ,
  created() {
    this.initGoodsTypeTree()
    this.initOrganTree(() => {
      this.setOrganQueryType()
    }, getOrganPath())
    this.handleGetStore()
    this.initOrganFormTree()
    this.handleFiltTenant()
    this.handleFiltSupplier()
    this.handleBuildGoogsImgTypeOptions()
    this.handleBuildMeasurementTypeOptions()
    this.handleBuildFreightTemplateOptions()
    this.handleBuildGoodsTypeBrandList()
    this.fetchData()
  },
  methods: {
    translateOrgan(row) {
      return translateOrganId2OrganName(row);
    },
    setOrganQueryType() {
      this.organQueryModel = localStorageUtil.fetch("SYSTEM_SETTING_ORGAN_QUERY_MODEL")
      this.organQueryModelChange(this.organQueryModel)
    },
    fetchData() {
      this.createOrganQuery()
      this.currentPage = this.currentPage || 1
      this.pageSize = this.pageSize || 10
      this.listLoading = true
      getList(this.query.params, this.currentPage, this.pageSize).then(response => {
        const data = response.data
        if (!data.entities || typeof data.successful != 'undefined') {
          this.$message({
            type: 'info',
            message: data.description || getSystemErrorCode(data.status)
          })
        }
        this.total = data.totalCount
        this.pageSize = data.pageSize
        this.currentPage = data.currentPage
        this.list = data.entities
        this.listLoading = false
      })
    },
    handleSizeChange(val) {
      this.currentPage = 1
      this.pageSize = val
      this.fetchData()
    },
    handleCurrentChange(val) {
      this.currentPage = val
      this.fetchData()

    },
    createOrganQuery() {
      // 选中了租户
      let tenantSelected = this.$refs['tenantTree'] && this.$refs['tenantTree'].getCheckedNodes() || []
      let organSelected = this.$refs['organTree'] && this.$refs['organTree'].getCheckedNodes() || []
      let that = this
      this.query.params.organId = null
      if (tenantSelected.length && tenantSelected[0]) {
        this.query.params.tenantId = tenantSelected[0].data.id
        if (organSelected.length && organSelected[0]) {
          if (this.props.multiple) {
            this.query.params.organId = null
            this.query.params.organIds = []
            if (organSelected.length && organSelected[0]) {
              organSelected.forEach(function (element) {
                that.query.params.organIds.push(element.data.id)
              })
            }
          } else if (organSelected.length && organSelected[0]) {
            this.query.params.organPath = organSelected[0] && organSelected[0].data.organPath
          }
        }
      } else {
        this.query.params.tenantId = getTenantId()
        if (organSelected.length && organSelected[0]) {
          if (this.props.multiple) {
            this.query.params.organId = null
            this.query.params.organIds = []
            if (organSelected.length && organSelected[0]) {
              organSelected.forEach(function (element) {
                that.query.params.organIds.push(element.data.id)
              })
            }
          } else if (organSelected.length && organSelected[0]) {
            this.query.params.organPath = organSelected[0].data.organPath
          }
        }

      }
      this.query.params.organId = this.query.params.organId || getOrganId()
      this.query.params.organPath = this.query.params.organPath || getOrganPath()
    },
    handleGoodsImgEditSave() {
      this.listLoading = true
      this.goodsImg.createBy = getCurrentLoginUserId()
      this.goodsImg.updateBy = getCurrentLoginUserId()
      doUploadImg(this.goodsImg).then(response => {
        let data = response.data
        if (data.successful) {
          this.$message({
            type: 'success',
            message: '操作成功!'
          })
          this.fetchData();
        } else {
          this.$message({
            type: 'info',
            message: data.description || getSystemErrorCode(data.status)
          })
        }
        this.listLoading = false
        this.dialogFormGoodsImgAddVisible = false
      })
    },
    handleGetGoodsImgs(index, row) {

      this.listLoading = true
      this.goodsImgUrls = []
      this.goodsImgUrls.push(row.goodsImg)
      this.query.goodsImg.organId = row.organId || getOrganId()
      this.query.goodsImg.organPath = row.organPath || getOrganPath()
      this.query.goodsImg.goodsId = row.id
      this.query.goodsImg.tenantId = row.tenantId || getTenantId()
      getGoodsImgByGoods(this.query.goodsImg).then(response => {
        debugger
        const gateway = response.data
        if (gateway.successful) {
          let data = gateway.data
          for (let i = 0; i < data.length; i++) {
            this.goodsImgUrls.push(data[i].imgUrl)
          }

        } else {
          this.$message({
            type: 'info',
            message: data.description || getSystemErrorCode(data.status)
          })
        }

        this.listLoading = false
        // 新增弹框标题
        this.dialogStatus = 'showGoodsImgs'
        this.dialogForGoodsImgVisible = true
      })
    },
    handleGoodsImgAdd(index, row) {

      // 显示弹框
      this.dialogFormGoodsImgAddVisible = true

      this.addForGoodsImgVisible = false

      // 新增弹框标题
      this.dialogStatus = 'addGoodsImg'

      this.goodsImg.id = ''
      this.goodsImg.goodsId = row.id
      this.goodsImg.imgUrl = ''
      this.goodsImg.imgType = ''
      this.goodsImg.folder = ''
      this.goodsImg.sort = ''
      this.goodsImg.organId = getOrganId()
      this.goodsImg.organPath = getOrganPath()
      this.goodsImg.tenantId = getTenantId()
      this.goodsImg.createBy = ''
      this.goodsImg.createDate = ''
      this.goodsImg.updateBy = ''
      this.goodsImg.updateDate = ''
      this.goodsImg.isDeleted = ''
      this.goodsImg.remark = ''
    },
    handleGetGoodsImg(index, row) {

    },
    handleDefaultSelected(selectedNodes) {
      for (let i = 0; i < selectedNodes.length; i++) {
        this.$refs.assigneeTree.setChecked(selectedNodes[i].organId, true, false)
      }
    },
    getCheckedNodes() {
      let nodesInfo = this.$refs['assigneeTree'].getCheckedNodes()
      let that = this
      that.goodsAssignees.assignees = []
      nodesInfo.forEach(function (organ) {
        that.goodsAssignees.assignees.push({
          organId: organ.id,
          tenantId: organ.tenantId,
          organPath: organ.organPath,
          createBy: getCurrentLoginUserId(),
          updateBy: getCurrentLoginUserId()
        })
      })
      assign2Organs(this.goodsAssignees).then(response => {
        const gateway = response.data
        let data = gateway.data
        if (data.successful) {
          this.$message({
            type: 'success',
            message: '操作成功!'
          })
          this.fetchData();
        } else {
          this.$message({
            type: 'info',
            message: data.description || getSystemErrorCode(data.status)
          })
        }
        this.listLoading = false
      })

    },
    // 新增
    handleAdd() {
      // 显示弹框
      this.dialogFormVisible = true
      // 新增弹框标题
      this.dialogStatus = 'add'

      this.form.id = ''
      this.form.organId = ''
      this.form.organPath = ''
      this.form.organName = ''
      this.form.goodsTypeId = ''
      this.form.goodsTypePath = ''
      this.form.goodsName = ''
      this.form.supplierId = ''
      this.form.goodsImg = ''
      this.form.goodsDescribe = ''
      this.form.unit = ''
      this.form.unitValue = ''
      this.form.productionPlace = ''
      this.form.sys = ''
      this.form.isDeleted = ''
      this.form.quote = ''
      this.form.createBy = ''
      this.form.createDate = ''
      this.form.updateBy = ''
      this.form.updateDate = ''
      this.form.remark = ''
      this.addForVisible = false
    },
    // 编辑
    handleEdit(index, row) {
      console.log(index)
      console.log(row)
      this.form.id = row.id
      this.form.organId = row.organId
      this.form.tenantId = row.tenantId
      this.form.goodsTypeId = row.goodsTypeId
      this.form.organPath = row.organPath
      this.form.organName = row.organName
      this.form.goodsTypePath = row.goodsTypePath
      this.form.goodsName = row.goodsName
      this.form.supplierId = row.supplierId
      this.form.goodsImg = row.goodsImg
      this.form.goodsDescribe = row.goodsDescribe
      this.form.unit = row.unit
      this.form.unitValue = row.unitValue
      this.form.productionPlace = row.productionPlace
      this.form.measurementType = row.measurementType
      this.form.sys = row.sys
      this.form.isDeleted = row.isDeleted
      this.form.quote = row.quote
      this.form.createBy = row.createBy
      this.form.createDate = row.createDate
      this.form.updateBy = row.updateBy
      this.form.updateDate = row.updateDate
      this.form.remark = row.remark
      this.addForVisible = true
      // 显示弹框
      this.dialogFormVisible = true
      // 编辑弹框标题
      this.dialogStatus = 'edit'
    },
    handleDelete(index, row) {
      console.log(index)
      console.log(row)

      this.$confirm('此操作将永久删除该记录, 是否继续?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning',
        center: true
      }).then(() => {
        this.listLoading = true
        doDelete(row.id).then(response => {
          const gateway = response.data
          let data = gateway.data
          if (gateway.successful) {
            this.$message({
              type: 'success',
              message: '操作成功!'
            })
            this.fetchData();
          } else {
            this.$message({
              type: 'info',
              message: gateway.description || getSystemErrorCode(gateway.status)
            })
          }
          this.listLoading = false
        })
      }).catch(() => {
        this.listLoading = false
        this.$message({
          type: 'info',
          message: '已取消删除'
        })
      })
    },
    handleEditSave() {
      this.$refs['goodsForm'].validate((valid) => {
        if (valid) {
          this.listLoading = true
          this.form.createBy = getCurrentLoginUserId()
          this.form.updateBy = getCurrentLoginUserId()
          this.form.assignee = { id: getOrganId(), organPath: getOrganPath() }
          doEdit(this.form).then(response => {
            let data = response.data
            if (data.successful) {
              this.$message({
                type: 'success',
                message: '操作成功!'
              })
              this.fetchData();
            } else {
              this.$message({
                type: 'info',
                message: data.description || getSystemErrorCode(data.status)
              })
            }
            this.listLoading = false
            this.dialogFormVisible = false
          })
        }
      });
    },
    handleRemove(file, fileList) {
      console.log(file, fileList);
      delete this.imageMap[file.uid]
    },
    handlePreview(file) {
      console.log(file);
    },
    handleExceed(files, fileList) {
      this.$message.warning(`当前限制选择 1 个文件，本次选择了 ${files.length} 个文件，共选择了 ${files.length + fileList.length} 个文件`);
    },
    beforeRemove(file, fileList) {
      return this.$confirm(`确定移除 ${file.name}？`);
    },
    handleReset() {
      this.$confirm('此操作将永久删除该记录, 是否继续?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning',
        center: true
      }).then(() => {
        this.$message({
          type: 'success',
          message: '删除成功!'
        })
      }).catch(() => {
        this.$message({
          type: 'info',
          message: '已取消删除'
        })
      })
    },
    uploadFileOnSuccess(response, file, fileList) {
      if (!response.data.successful) {
        this.$message({
          type: 'warning',
          message: response.description
        })
        return;
      }
      this.form.goodsImg = response.data.data.fileUrl
    },
    uploadImageOnSuccess(response, file, fileList) {
      if (!response.data.successful) {
        this.$message({
          type: 'warning',
          message: response.description
        })
        return;
      }
      this.goodsImg.imgUrl = response.data.data.fileUrl
      if (file && file.uid) {
        this.imageMap[file.uid] = response.data.data.fileUrl
      }
      console.log(this.imageMap)
    },
    handleAfterUploadSuccess(response, file, fileList) {
      if (!response.data.successful) {
        this.$message({
          type: 'warning',
          message: response.description
        })
        return;
      }

      this.form.goodsImgs.push(response.data.data.fileUrl)

    },
    initOrganTree(fn, filter, that) {
      this.listLoading = true
      let data = getOrganList()
      if (filter) {
        data = data.filter(function (item, index) {
          return item.organPath.indexOf(filter) >= 0
        })
      }
      if (that && that.organFormOptions && that.organFormOptions.length >= 0) {
        that.organFormOptions = handleBuildTreeDataStruct(data, 'id', 'parentId')
      } else {
        this.organOptions = handleBuildTreeDataStruct(data, 'id', 'parentId')
      }
      this.listLoading = false
      if (fn) {
        fn()
      }
    },
    initOrganFormTree(fn, filter) {
      this.initOrganTree(fn, filter, this)
    },
    setOrganQueryType() {
      this.organQueryModelChange(localStorageUtil.fetch("SYSTEM_SETTING_ORGAN_QUERY_MODEL"))
    },
    selectOrgan(nodes) {
      let nodesInfo = this.$refs['organTree'].getCheckedNodes()
      let that = this
      this.query.params.organPath = ''
      this.query.params.organIds = []
      if (this.props.multiple) {
        this.query.params.organIds = []
        if (nodesInfo.length) {
          nodesInfo.forEach(function (element) {
            that.query.params.organIds.push(element.data.id)
          })
        }
      } else if (nodesInfo.length) {
        this.query.params.organPath = nodesInfo[0].data.organPath
      }
    },
    selectTenant(nodes) {
      let nodesInfo = this.$refs['tenantTree'].getCheckedNodes()
      let that = this
      this.query.params.tenantId = ''
      this.query.params.tenantIds = []
      this.query.params.organId = null
      this.query.params.organIds = []
      this.query.params.organPath = null

      if (this.tenantProps.multiple) {
        this.query.params.tenantIds = []
        if (nodesInfo.length) {
          nodesInfo.forEach(function (element) {
            that.query.params.tenantIds.push(element.data.id)
          })
        }
      } else if (nodesInfo.length) {
        this.query.params.tenantId = nodesInfo[0].data.id
        this.initOrganTree(function () {
          that.setOrganQueryType()
        }, nodesInfo[0].data.organPath)
      } else {
        this.initOrganTree(function () {
          that.setOrganQueryType()
        })
      }
    },
    chooseTenantForm(nodes) {
      let nodesInfo = this.$refs['tenantTreeForm'].getCheckedNodes()
      this.form.tenantId = null
      let that = this
      if (nodesInfo.length) {
        this.form.tenantId = nodesInfo[0].data.id
        this.initOrganFormTree(function () {
          that.setOrganQueryType()
        }, nodesInfo[0].data.organPath, this.organFormOptions)
      } else {
        this.initOrganFormTree(function () {
          that.setOrganQueryType()
        }, null, this.organFormOptions)
      }
    },
    chooseTenant(form) {
      let nodesInfo = this.$refs['tenantTreeForm'].getCheckedNodes()
      form.tenantId = null
      let that = this
      if (nodesInfo.length) {
        form.tenantId = nodesInfo[0].data.id
        this.initOrganFormTree(function () {
          that.setOrganQueryType()
        }, nodesInfo[0].data.organPath, this.organFormOptions)
      } else {
        this.initOrganFormTree(function () {
          that.setOrganQueryType()
        }, null, this.organFormOptions)
      }
    },
    organQueryModelChange(organQueryModel) {
      if (organQueryModel == 'selected') {
        this.props.multiple = true
      } else if (organQueryModel == 'selfAndSub') {
        this.props.multiple = false
      }
    },
    chooseOrganForm(nodes) {
      let nodesInfo = this.$refs['organTreeForm'].getCheckedNodes()
      if (nodesInfo[0]) {
        this.form.organPath = nodesInfo[0].data.organPath
        this.form.organId = nodesInfo[0].data.id
        this.form.tenantId = nodesInfo[0].data.tenantId
      }
    },
    handleFiltTenant() {
      let data = getOrganList()
      this.tenantOptions = data.filter(function (item, index) {
        return item.type == 0 || item.type == 1;
      })
    },
    handleFiltSupplier() {
      let data = getOrganList()
      this.supplierOptions = data.filter(function (item, index) {
        return item.type == 99;
      })
    },
    initGoodsTypeTree() {
      this.listLoading = true
      getGoodsTypeTree({ organId: getOrganId() }).then(response => {
        console.log(response)
        const data = response.data.data
        this.goodsTypeTreeOptions = handleBuildTreeDataStruct(data, 'id', 'parentId')
        this.listLoading = false
      })
    },
    selectSpecificationGroup() {
      let nodesInfo = this.$refs['specificationGroupTree'].getCheckedNodes()
      this.query.goodsSpecification.groupId = nodesInfo[0].data.id
    },
    handleQueryGoodsSpecificationCurrentChange(val) {

    },
    handleGoodsSpecification2OrganSave() {

    },
    handleQueryGoodsSpecificationSizeChange() {

    },
    handleAssignOrganSave() {
      this.listLoading = true
      assign2Organs(this.assign2Organs).then(response => {
        const gateway = response.data
        let data = gateway.data
        if (data.successful) {
          this.$message({
            type: 'success',
            message: '操作成功!'
          })
          this.fetchData();
        } else {
          this.$message({
            type: 'info',
            message: data.description || getSystemErrorCode(data.status)
          })
        }
        this.listLoading = false
      })
    },
    handleOrganSelectionChange(val) {

      this.assign2Organs.assignees = val
      this.assign2Organs.createBy = getCurrentLoginUserId()
      this.assign2Organs.updateBy = getCurrentLoginUserId()
    },
    getGoodsTypeValue(value) {
      this.goodsTypeValueId = value
      if (value) {
        this.query.params.typePath = value.typePath
      } else {
        this.query.params.typePath = ''
      }
    },
    getValue(value) {
      this.valueId = value
      if (value) {
        this.query.params.organPath = value.organPath
      } else {
        this.query.params.organPath = getOrganPath()
      }
      console.log(this.valueId)
    },
    getSupplier(value) {
      let nodesInfo = this.$refs['applyerTree'].getCheckedNodes()
      this.form.supplierId = nodesInfo[0].data.id
    },
    getGoodsType(form) {
      let nodesInfo = this.$refs['goodsTypeTreeForm'].getCheckedNodes()
      form.goodsTypeId = nodesInfo[0].data.id
      form.goodsTypePath = nodesInfo[0].data.typePath
    },
    handleBuildGoogsImgTypeOptions() {

      const datas = getDictionary()
      let data = datas.filter(function (item, index) {
        return item.bigType === "GoogsImgType" && item.parentId != '0';
      })
      let googsImgTypeOptions = [];
      for (let i = 0; i < data.length; i++) {
        let option = {}
        option['value'] = data[i].value
        option['label'] = data[i].desc
        googsImgTypeOptions.push(option)
      }
      this.query.googsImgTypeOptions = googsImgTypeOptions
    },

    handleBuildMeasurementTypeOptions() {
      const datas = getDictionary()
      let data = datas.filter(function (item, index) {
        return item.bigType === "GoodsUnitOfMeasurement" && item.parentId == '0';
      })
      let measurementTypeOptions = [];
      for (let i = 0; i < data.length; i++) {
        let option = {}
        option['value'] = data[i].code
        option['label'] = data[i].desc
        measurementTypeOptions.push(option)
      }
      this.query.measurementTypeOptions = measurementTypeOptions
    },
    handleInitMeasurementUnitOptions(obj) {
      this.handleBuildMeasurementUnitOptions(obj.measurementType)
    },
    handleBuildMeasurementUnitOptions(code) {
      const datas = getDictionary()
      let data = datas.filter(function (item, index) {
        return item.bigType === "GoodsUnitOfMeasurement" && item.parentId != '0' && item.nameSpace === ('GOODS_UINT_OF_MEASUREMENT.' + code);
      })
      let measurementUnitOptions = [];
      for (let i = 0; i < data.length; i++) {
        let option = {}
        option['value'] = data[i].value
        option['label'] = data[i].desc
        measurementUnitOptions.push(option)
      }
      this.query.measurementUnitOptions = measurementUnitOptions
    },


    handleAddGoodsPrice(index, row) {

      this.dialogFormGoodsPriceVisible = true
      this.addForGoodsPriceVisible = false
      if (row) {
        this.goodsPrice.id = ''
        this.goodsPrice.goodsId = row.id
        this.goodsPrice.goodsName = row.goodsName
        this.goodsPrice.goodsCode = ''
        this.goodsPrice.goodsTypeId = row.goodsTypeId
        this.goodsPrice.goodsTypePath = row.goodsTypePath
        this.goodsPrice.tenantId = row.tenantId || getTenantId()
        this.goodsPrice.organId = row.organId || getOrganId()
        this.goodsPrice.organPath = row.organPath || getOrganPath()
        this.goodsPrice.goodsTypeId = row.goodsTypeId
        this.goodsPrice.goodsTypePath = row.goodsTypePath
        this.goodsPrice.isDeleted = ''
        this.goodsPrice.createBy = getCurrentLoginUserId()
        this.goodsPrice.createDate = ''
        this.goodsPrice.updateBy = getCurrentLoginUserId()
        this.goodsPrice.updateDate = ''
        this.goodsPrice.unit = row.unit
        this.goodsPrice.stockCount = row.unitValue
        this.goodsPrice.remark = ''
        this.goodsPrice.price = ''
      }

    },
    handleModifyGoodsPrice(index, row) {

      this.dialogFormGoodsPriceVisible = true
      this.addForGoodsPriceVisible = true

      this.goodsPrice.id = row.id
      this.goodsPrice.goodsId = row.goodsId
      this.goodsPrice.goodsName = row.goodsName
      this.goodsPrice.goodsCode = row.goodsCode
      this.goodsPrice.tenantId = row.tenantId || getTenantId()
      this.goodsPrice.organId = row.organId || getOrganId()
      this.goodsPrice.organPath = row.organPath || getOrganPath()
      this.goodsPrice.isDeleted = row.isDeleted
      this.goodsPrice.remark = row.remark
      this.goodsPrice.goodsTypeId = row.goodsTypeId
      this.goodsPrice.goodsTypePath = row.goodsTypePath
      this.goodsPrice.price = row.price
      this.goodsPrice.costPrice = row.costPrice
      this.goodsPrice.discountPrice = row.discountPrice
      this.goodsPrice.suggestedRetailPrice = row.suggestedRetailPrice
      this.goodsPrice.createDate = row.createDate
      this.goodsPrice.updateDate = row.updateDate
    },
    handleAddGoodsPriceSave() {
      this.$refs['goodsPriceForm'].validate((valid) => {
        if (valid) {
          this.listLoading = true
          this.goodsPrice.createBy = getCurrentLoginUserId()
          saveGoodsPrice(this.goodsPrice).then(response => {
            let data = response.data
            if (data.successful) {
              this.$message({
                type: 'success',
                message: '操作成功!'
              })
              this.fetchData();
            } else {
              this.$message({
                type: 'info',
                message: data.description || getSystemErrorCode(data.status)
              })
            }
            this.dialogFormGoodsPriceVisible = false
            this.addForGoodsPriceVisible = false
          })
        }
      });

    },
    handleShowGoodsPriceList(index, row) {

      this.query.goodsPrice.currentPage = 1
      this.query.goodsPrice.pageSize = 10
      this.dialogShowGoodsPriceListAddVisible = true
      this.goodsPriceList = []
      this.query.goodsPrice.goodsId = row.id
      this.query.goodsPrice.organId = row.organId || getOrganId()
      this.query.goodsPrice.organPath = row.organPath || getOrganPath()
      this.query.goodsPrice.tenantId = row.tenantId || getTenantId()
      this.goodsPrice.goodsId = row.goodsId
      this.goodsPrice.goodsName = row.goodsName
      this.goodsPrice.goodsCode = row.goodsCode
      this.goodsPrice.tenantId = row.tenantId || getTenantId()
      this.goodsPrice.organId = row.organId || getOrganId()
      this.goodsPrice.organPath = row.organPath || getOrganPath()
      this.goodsPrice.isDeleted = row.isDeleted
      this.goodsPrice.remark = row.remark
      this.goodsPrice.goodsTypeId = row.goodsTypeId
      this.goodsPrice.goodsTypePath = row.goodsTypePath
      this.goodsPrice.price = row.price
      this.goodsPrice.costPrice = row.costPrice
      this.goodsPrice.discountPrice = row.discountPrice
      this.goodsPrice.suggestedRetailPrice = row.suggestedRetailPrice
      this.goodsPrice.createDate = row.createDate
      this.goodsPrice.updateDate = row.updateDate

      this.handleQueryGoodsPrice()

    },
    handleGoodsPriceCurrentChange(val) {

      this.query.goodsPrice.currentPage = val
      this.handleQueryGoodsPrice()
    },
    handleGoodsPriceSizeChange(val) {
      this.query.goodsPrice.currentPage = 1
      this.query.goodsPrice.pageSize = val
      this.handleQueryGoodsPrice()

    },
    handleQueryGoodsPrice() {
      this.listLoading = true
      getGoodsPriceList(this.query.goodsPrice,
        this.query.goodsPrice.currentPage,
        this.query.goodsPrice.pageSize).then(response => {
          const data = response.data
          this.query.goodsPrice.total = data.totalCount
          this.query.goodsPrice.pageSize = data.pageSize
          this.query.goodsPrice.currentPage = data.currentPage
          this.goodsPriceList = data.entities
          this.listLoading = false
        })
    },
    handleDeleteGoodsPrice(index, row) {

      console.log(index)
      console.log(row)
      this.$confirm('此操作将永久删除该记录, 是否继续?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning',
        center: true
      }).then(() => {
        deleteGoodsPrice(row.id).then(response => {
          const gateway = response.data
          let data = gateway.data
          if (data.successful) {
            this.$message({
              type: 'success',
              message: '操作成功!'
            })
            this.handleQueryGoodsPrice()
          } else {
            this.$message({
              type: 'info',
              message: data.description || getSystemErrorCode(data.status)
            })
          }
        })
      }).catch(() => {
        this.$message({
          type: 'info',
          message: '已取消删除'
        })
      })
    },

    selectGoodsType(nodes) {
      let nodesInfo = this.$refs['goodsTypeTree'].getCheckedNodes()
      this.query.params.goodsTypeId = nodesInfo[0].data.id
    },
    selectGoodsTypeBrand(form) {
      let nodesInfo = this.$refs['goodsTypeBrandTree'].getCheckedNodes()
      form.brandId = nodesInfo[0].data.brandId
    },
    selectFreightTemplate(goods) {
      let nodesInfo = this.$refs['freightTemplateTree'].getCheckedNodes()
      goods['freightTemplateIds'] = []
      if (this.freightTemplateProps.multiple) {
        for (let i = 0; i < nodesInfo.length; i++) {
          goods.freightTemplateIds.push(nodesInfo[i].data.id)
        }
      } else {
        goods.freightTemplateIds.push(nodesInfo[0].data.id)
      }

    },
    selectSupplier(nodes) {
      let nodesInfo = this.$refs['supplierTree'].getCheckedNodes()
      if (nodesInfo.length) {
        this.query.params.supplierId = nodesInfo[0].data.id
      } else {
        this.query.params.supplierId = null
      }
    },
    handleBindGoodsSpecification(index, row) {
      this.dialogFormShowGoodsSpecificationVisible = true

    },
    queryGoodsAssignee() {
      queryGoodsAssignee(row.id).then(response => {
        const gateway = response.data
        let data = gateway.data
        if (data.successful) {
          this.$message({
            type: 'success',
            message: '操作成功!'
          })
          this.handleQueryGoodsPrice()
        } else {
          this.$message({
            type: 'info',
            message: data.description || getSystemErrorCode(data.status)
          })
        }
      })
    },
    handleAssignToOrgan(index, row) {
      this.dialogStatus = 'assignOrgan'
      this.goodsAssignees.id = row.id
      this.goodsAssignees.organId = row.organId
      this.goodsAssignees.tenantId = row.tenantId
      this.listLoading = true
      this.dialogFormOrganVisible = true
      this.query.organParams.organPath = getOrganPath()
      this.query.goodsOrganQuery.id = row.id

      queryAssigneeOrgan(this.query.organParams).then(response => {
        const pager = response.data
        this.organTree = handleBuildTreeDataStruct(pager.data, 'id', 'parentId')
        this.listLoading = false
        queryAlreadyAssignedOrgans(this.query.goodsOrganQuery).then(response => {
          const data = response.data
          const selectedNodes = data.data
          this.$nextTick(function () {
            this.handleDefaultSelected(selectedNodes)
          })
        })
      })

    },
    handleDefaultSelected(selectedNodes) {
      for (let i = 0; i < selectedNodes.length; i++) {
        this.$refs.assigneeTree.setChecked(selectedNodes[i].organId, true, false)
      }
    },
    handleQueryGoodsTypeSpecification() {
      this.listLoading = true
      this.query.goodsSpecification.currentPage = 1
      this.query.goodsSpecification.pageSize = 10
      this.query.goodsSpecification.organId = getOrganId()
      this.query.goodsSpecification.organPath = getOrganPath()
      this.query.goodsSpecification.tenantId = getTenantId()
      queryGoodsTypeSpecification(this.query.goodsSpecification,
        this.query.goodsSpecification.currentPage,
        this.query.goodsSpecification.pageSize
      ).then(response => {
        const pager = response.data
        this.goodsSpecificationList = pager.entities
        this.query.goodsSpecification.pageSize = pager.pageSize
        this.query.goodsSpecification.total = pager.totalCount
        this.query.goodsSpecification.currentPage = pager.currentPage
        this.listLoading = false
      })

    },

    handleQueryGoodsTypePropsPage() {
      this.query.goodsTypeProps.goodsTypeId = this.form.goodsTypeId
      this.query.goodsTypeProps.organId = getOrganId()
      this.query.goodsTypeProps.organPath = getOrganPath()
      this.query.goodsTypeProps.tenantId = getTenantId()
      //this.query.goodsTypeProps.isMust = true
      this.listLoading = true
      queryGoodsTypePropsPage(this.query.goodsTypeProps,
        this.query.goodsTypeProps.currentPage,
        this.query.goodsTypeProps.pageSize).then(response => {
          const data = response.data
          this.total = data.totalCount
          this.query.goodsTypeProps.pageSize = data.pageSize
          this.query.goodsTypeProps.currentPage = data.currentPage
          this.goodsTypePropsList = data.entities
          this.listLoading = false
        })
    },
    handleShowQueryGoodsTypeProps() {
      this.dialogFormShowGoodsPropsVisible = true
      this.handleQueryGoodsTypePropsPage()
    },
    handleQueryGoodsTypePropsItem() {
      this.choosePropNodesMap = {}
      this.propValueMap = {}
      this.query.goodsTypePropsItem.goodsPropsIds = []
      if (this.chooseGoodsTypePropsNodes && this.chooseGoodsTypePropsNodes.length) {
        for (let i = 0; i < this.chooseGoodsTypePropsNodes.length; i++) {
          this.query.goodsTypePropsItem.goodsPropsIds.push(this.chooseGoodsTypePropsNodes[i].id)
          this.choosePropNodesMap[this.chooseGoodsTypePropsNodes[i].id] = this.chooseGoodsTypePropsNodes[i]
          this.chooseGoodsTypePropsNodes[i]['goodsTypePropValues'] = []
          this.chooseGoodsTypePropsNodes[i]['goodsTypePropValuesSelected'] = []
        }
      }
      let that = this
      this.query.goodsTypePropsItem.organId = getOrganId()
      this.query.goodsTypePropsItem.organPath = getOrganPath()
      this.query.goodsTypePropsItem.tenantId = getTenantId()
      queryGoodsTypePropsValueForList(this.query.goodsTypePropsItem).then(response => {
        let data = response.data
        if (data.successful) {
          that.goodsTypePropsValueList = data.data
          for (let i = 0; i < that.goodsTypePropsValueList.length; i++) {
            that.choosePropNodesMap[that.goodsTypePropsValueList[i].goodsPropsId]['goodsTypePropValues'].push(that.goodsTypePropsValueList[i])
            that.choosePropNodesMap[that.goodsTypePropsValueList[i].goodsPropsId]['selected'] = true
            that.propValueMap[that.goodsTypePropsValueList[i].id] = that.goodsTypePropsValueList[i]
          }
        } else {
          that.$message({
            type: 'info',
            message: data.description || getSystemErrorCode(data.status)
          })
        }
        that.dialogFormShowGoodsPropsVisible = false
      })

    },
    handleGoodsTypePropsToSPU() {
      this.handleQueryGoodsTypePropsItem()
    },
    handleGoodsPropSelectionChange(selectedNodes) {
      this.chooseGoodsTypePropsNodes = selectedNodes
    },
    handleGoodsTypePropsChange(updatedVals) {
      let propMap = {}
      // 清除上次的选择
      for (let key in this.choosePropNodesMap) {
        this.choosePropNodesMap[key].goodsTypePropValuesSelected = []
      }
      for (let i = 0; i < updatedVals.length; i++) {
        this.choosePropNodesMap[this.propValueMap[updatedVals[i]].goodsPropsId]
          .goodsTypePropValuesSelected.push(this.propValueMap[updatedVals[i]])
      }

    },
    handleShowGoodsSpecification() {
      this.dialogFormShowGoodsSpecificationVisible = true
      this.query.goodsSpecificationGroup.organId = getOrganId()
      this.query.goodsSpecificationGroup.organPath = getOrganPath()
      this.query.goodsSpecificationGroup.tenantId = getTenantId()
      this.handleQueryGoodsSpecificationGroup()
    },
    handleQueryGoodsSpecificationGroup() {
      querySpecificationGroupList(this.query.goodsSpecificationGroup).then(response => {
        let data = response.data
        if (data.successful) {
          this.specificationGroupOptions = handleBuildTreeDataStruct(data.data, 'id', 'parentId')
        } else {
          this.$message({
            type: 'info',
            message: data.description || getSystemErrorCode(data.status)
          })
        }
      });
    },
    handleGoodsSpecificationToSPU() {
      this.handleQueryGoodsSpecificationItem()
    },
    handleQueryGoodsSpecificationSizeChange(val) {

    },
    handleQueryGoodsSpecificationCurrentChange(val) {

    },
    handleShowGoodsSpecificationItem(index, row) {

      this.dialogShowGoodsSpecificationItemVisable = true
      this.query.goodsSpecificationItem.specificationId = row.id
      this.query.goodsSpecificationItem.specificationIds = []
      this.query.goodsSpecificationItem.organId = row.organId || getOrganId()
      this.query.goodsSpecificationItem.organPath = row.organPath || getOrganPath()
      this.query.goodsSpecificationItem.tenantId = row.tenantId || getTenantId()
      this.handleQueryGoodsTypeSpecificationItemPage()
    },
    handleQueryGoodsTypeSpecificationItemPage() {
      this.query.goodsSpecificationItem.currentPage = 1
      this.query.goodsSpecificationItem.pageSize = 10
      queryGoodsTypeSpecificationItem(this.query.goodsSpecificationItem,
        this.query.goodsSpecificationItem.currentPage,
        this.query.goodsSpecificationItem.pageSize).then(response => {
          console.log(response)
          const pager = response.data

          this.query.goodsSpecificationItem.pageSize = pager.pageSize
          this.query.goodsSpecificationItem.currentPage = pager.currentPage
          this.query.goodsSpecificationItem.total = pager.totalCount
          this.goodsTypeSpecificationItemList = pager.entities

        })
    },
    handleQueryItemValSizeChange(val) {
      this.query.goodsSpecificationItem.currentPage = 1
      this.query.goodsSpecificationItem.pageSize = val
      this.handleQueryGoodsTypeSpecificationItemPage()
    },
    handleQueryItemCurrentChange(val) {
      this.query.goodsSpecificationItem.currentPage = val
      this.handleQueryGoodsTypeSpecificationItemPage()
    },
    handleGoodsSpecifiactionSelectionChange(selectedNodes) {
      this.chooseSpecificationNodes = selectedNodes
    },
    handleGoodsPropSelectionChange(selectedNodes) {
      this.chooseGoodsTypePropsNodes = selectedNodes
    },
    handleQueryGoodsSpecificationItem() {
      this.chooseSpecificationNodesMap = {}
      this.specificationItemMap = {}
      this.query.goodsSpecificationItem.specificationIds = []
      this.query.goodsSpecificationItem.specificationId = ''
      if (this.chooseSpecificationNodes && this.chooseSpecificationNodes.length) {
        for (let i = 0; i < this.chooseSpecificationNodes.length; i++) {
          this.query.goodsSpecificationItem.specificationIds.push(this.chooseSpecificationNodes[i].id)
          this.chooseSpecificationNodesMap[this.chooseSpecificationNodes[i].id] = this.chooseSpecificationNodes[i]
          this.chooseSpecificationNodes[i]['specificationItems'] = []
          this.chooseSpecificationNodes[i]['specificationItemsSelected'] = []
        }
      }
      let that = this
      this.query.goodsSpecificationItem.organId = getOrganId()
      this.query.goodsSpecificationItem.organPath = getOrganPath()
      this.query.goodsSpecificationItem.tenantId = getTenantId()
      queryGoodsSpecificationItemForList(this.query.goodsSpecificationItem).then(response => {
        let data = response.data
        if (data.successful) {
          debugger
          that.goodsSpecificationItems = data.data
          for (let i = 0; i < this.goodsSpecificationItems.length; i++) {
            that.chooseSpecificationNodesMap[that.goodsSpecificationItems[i].specificationId]['specificationItems'].push(that.goodsSpecificationItems[i])
            that.chooseSpecificationNodesMap[that.goodsSpecificationItems[i].specificationId]['selected'] = true
            that.specificationItemMap[that.goodsSpecificationItems[i].id] = that.goodsSpecificationItems[i]
          }

        } else {
          this.$message({
            type: 'info',
            message: data.description || getSystemErrorCode(data.status)
          })
        }
      });
    },
    handleGoodsSpecificationItemChange(updatedVals) {
      // 清除上次的选择
      for (let key in this.chooseSpecificationNodesMap) {
        this.chooseSpecificationNodesMap[key].specificationItemsSelected = []
      }
      // 此处对选择好的商品规格进行收集，准备做迪卡尔积运算
      for (let i = 0; i < updatedVals.length; i++) {
        this.chooseSpecificationNodesMap[this.specificationItemMap[updatedVals[i]].specificationId]
          .specificationItemsSelected.push(this.specificationItemMap[updatedVals[i]])
      }
    },
    handleBuildFreightTemplateOptions() {
      queryFreightTemplate({ organId: getOrganId(), tenantId: getTenantId(), organPath: getOrganPath() }).then(response => {
        const gateway = response.data
        if (gateway.successful) {
          let data = gateway.data
          this.freightTemplateOptions = handleBuildTreeDataStruct(data, 'id', 'parentId')

        } else {
          this.$message({
            type: 'info',
            message: data.description || getSystemErrorCode(data.status)
          })
        }

      })
    },
    handleLaunchGoodses() {
      this.drawer = true;
      this.form.organId = this.form.organId || getOrganId()
      this.form.tenantId = this.form.tenantId || getTenantId()
      this.form.organPath = this.form.organPath || getOrganPath()
      this.step = 1
    },
    handleClose(done) {
      this.$confirm('确认关闭商品发布操作吗？')
        .then(_ => {
          done();
        })
        .catch(_ => { });
    },
    handleNextStep() {
      if (this.step < 3) {
        this.step = ++this.step
        this.handleBuildGoodsTypeBrandOptions()
      }
    },
    handleBuildSPU() {
      this.form.status = 1
      this.handleBuildProps()
      this.handleBuildPropsValue()
      this.handleBuildSpecification()
      this.handleBuildSpecificationItem()
      this.handleBuildGoodsImgs()
      this.handleBuildGoodsExt()
      this.form.createBy = getCurrentLoginUserId(),
      this.form.createDate = getCurrentTimeYYYY_MM_dd_HH_mm_ss(),
      doLanuch(this.form).then(response => {
          let data = response.data
          if (data.successful) {
            this.$message({
              type: 'success',
              message: '操作成功!'
            })
            this.fetchData();
          } else {
            this.$message({
              type: 'info',
              message: data.description || getSystemErrorCode(data.status)
            })
          }
          this.listLoading = false
          this.dialogFormVisible = false
        })
    },
    handleBuildProps() {

      let props = []
      let distinctProps = {}
      for (let i = 0; i < this.skuPropsSpecifications.props.length; i++) {
        let tempProp = this.choosePropNodesMap[this.propValueMap[this.skuPropsSpecifications.props[i]].goodsPropsId]
        let goodsLinkProps = {
          createBy: getCurrentLoginUserId(),
          createDate: getCurrentTimeYYYY_MM_dd_HH_mm_ss(),
          goodsId: '',
          organId: getOrganId(),
          organPath: getOrganPath(),
          createBy: getCurrentLoginUserId(),
          tenantId: getTenantId(),
          propsId: tempProp.id,
          propCode: tempProp.propCode,
          propsValue: tempProp.propValue,
          propName: tempProp.propName,
          isMust: tempProp.isMust,
          isMutilSelect: tempProp.isMutilSelect,
          isNav: tempProp.isNav,
          sorted: '',
          status: '1',
          updateBy: getCurrentLoginUserId(),
          updateDate: getCurrentTimeYYYY_MM_dd_HH_mm_ss(),
        }
        if (!distinctProps[tempProp.id]) {
          props.push(goodsLinkProps)
          distinctProps[tempProp.id] = tempProp
        }
      }
      this.form.goodsLinkPropses = props;
    },
    handleBuildPropsValue() {

      let propsValues = []
      for (let i = 0; i < this.skuPropsSpecifications.props.length; i++) {
        let tempPropValue = this.propValueMap[this.skuPropsSpecifications.props[i]]
        let goodsLinkPropsValue = {

          createBy: getCurrentLoginUserId(),
          createDate: getCurrentTimeYYYY_MM_dd_HH_mm_ss(),
          goodsId: '', //商品编号,
          goodsPriceId: '', //关联组织商品价格（理论上这个字段是t_goods_price_organ的编号）,
          organId: getOrganId(),
          organPath: getOrganPath(),
          tenantId: getTenantId(),
          propsId: tempPropValue.goodsPropsId, //,
          propsValueId: tempPropValue.id, //属性编号,
          propsValueName: tempPropValue.goodsPropsValueName, //属性编号,
          propsValue: tempPropValue.goodsPropsValue,
          sorted: '', //,
          status: '', //,
          updateBy: getCurrentLoginUserId(),
          updateDate: getCurrentTimeYYYY_MM_dd_HH_mm_ss(),
        }
        propsValues.push(goodsLinkPropsValue)
      }
      this.form.goodsLinkPropsValues = propsValues;
    },
    handleBuildSpecification() {

      let specifications = []
      let distinctSpecification = {}

      // 此处对选择好的商品规格进行收集，准备做迪卡尔积运算
      for (let i = 0; i < this.skuPropsSpecifications.specifications.length; i++) {
        let tempSpecification = this.chooseSpecificationNodesMap[this.specificationItemMap[this.skuPropsSpecifications.specifications[i]].specificationId]

        let goodsLinkSpecification = {
          createBy: getCurrentLoginUserId(),
          createDate: getCurrentTimeYYYY_MM_dd_HH_mm_ss(),
          organId: getOrganId(),
          organPath: getOrganPath(),
          tenantId: getTenantId(),
          sorted: '',
          groupId:tempSpecification.groupId,
          specificationId: tempSpecification.id,
          specificationName: tempSpecification.parameterName,
          status: '1',
          updateBy: getCurrentLoginUserId(),
          updateDate: getCurrentTimeYYYY_MM_dd_HH_mm_ss(),
        }
        debugger
        if (!distinctSpecification[tempSpecification.id]) {
          specifications.push(goodsLinkSpecification)
          distinctSpecification[tempSpecification.id] = tempSpecification
        }
      }
      this.form.goodsLinkSpecifications = specifications;

    },
    handleBuildSpecificationItem() {

      let specificationItems = []
      // 此处对选择好的商品规格进行收集，准备做迪卡尔积运算

      for (let i = 0; i < this.skuPropsSpecifications.specifications.length; i++) {
        let tempSpecificationItem = this.specificationItemMap[this.skuPropsSpecifications.specifications[i]]

        let goodsLinkSpecificationItem = {
          createBy: getCurrentLoginUserId(),
          createDate: getCurrentTimeYYYY_MM_dd_HH_mm_ss(),
          organId: getOrganId(),
          organPath: getOrganPath(),
          tenantId: getTenantId(),
          sorted: '',
          specificationId: tempSpecificationItem.specificationId,
          specificationItemId: tempSpecificationItem.id,
          specificationValue: tempSpecificationItem.specificationValue,
          status: '',
          updateBy: getCurrentLoginUserId(),
          updateDate: getCurrentTimeYYYY_MM_dd_HH_mm_ss(),
        }
        specificationItems.push(goodsLinkSpecificationItem)
      }
      this.form.goodsLinkSpecificationItems = specificationItems;
    },
    handleBuildGoodsImgs() {
      let images = []
      for (let key in this.imageMap) {
        let goodsImage = {
          imgUrl: this.imageMap[key],
          imgType: 2,
          folder: '',
          sort: '',
          organId: getOrganId(),
          organPath: getOrganPath(),
          createBy: getCurrentLoginUserId(),
          tenantId: getTenantId(),
          createDate: '',
          updateBy: '',
          updateDate: '',
          remark: ''
        }
        images.push(goodsImage)
      }
      this.form.goodsImgs = images
    },
    handleBuildGoodsExt() {
      this.goodsExt.createBy = getCurrentLoginUserId()
      this.goodsExt.createDate = getCurrentTimeYYYY_MM_dd_HH_mm_ss()
      this.goodsExt.organId = getOrganId()
      this.goodsExt.tenantId = getTenantId()
      this.goodsExt.organPath = getOrganPath()
      this.goodsExt.status = 1
      this.form.goodsExt = this.goodsExt
    },
    handleBuildGoodsTypeBrandList() {
      let params = {
        organId: getOrganId(),
        organPath: getOrganPath(),
        tenantId: getTenantId()
      }
      queryGoodsTypeBrand(params).then(response => {
        const gateway = response.data
        let data = gateway.data
        if (gateway.successful) {
          this.$message({
            type: 'success',
            message: '操作成功!'
          })
          this.goodsTypeBrandList = gateway.data
        } else {
          this.$message({
            type: 'info',
            message: gateway.description || getSystemErrorCode(gateway.status)
          })
        }
      })

    },
    handleBuildGoodsTypeBrandOptions() {
      let that = this
      let goodsTypeBrandList = that.goodsTypeBrandList.filter(function (item, index) {
        return item.goodsTypeId == that.form.goodsTypeId;
      })
      that.goodsTypeBrandOptions = handleBuildTreeDataStruct(goodsTypeBrandList, 'id', 'parentId')
    },
    handleGetStore() {
      this.listLoading = true
      this.query.store.organPath = this.form.organPath || getOrganPath()
      this.query.store.tenantId = this.form.tenantId || getTenantId()
      getStoreList(this.query.store).then(response => {
        debugger
        const gateway = response.data
        let data = gateway.data
        if (gateway.successful) {
          this.storeList = data
          this.storeMap = {}
          this.handleCreateTranslater(this.storeList, this.storeMap, 'storeName')

        } else {
          this.$message({
            type: 'info',
            message: data.description || getSystemErrorCode(data.status)
          })
        }

        this.listLoading = false
      })
    },
    handleCreateTranslater(list, map, key) {
      if (list && list.length) {
        for (let i = 0; i < list.length; i++) {
          let item = list[i]
          map[item.id] = item[key]
        }
      }
    },
    chooseStore(storeId) {
      this.form.storeId = storeId
    },
    handleSelectionChange(selections) {
      debugger
      this.selectionsToOnline = selections
    },

    handleManageStatus(status) {
      if (this.selectionsToOnline && this.selectionsToOnline.length <= 0) {
        this.$message({
          type: 'danger',
          message: '请勾选需要操作的产品!'
        })
        return;
      }
      let goodsIds = []
      for (let i = 0; i < this.selectionsToOnline.length; i++) {
        goodsIds.push(this.selectionsToOnline[i].id)
      }
      let goodsVO = {
        'goodsIds': goodsIds,
        'createBy': getCurrentLoginUserId(),
        'createDate': getCurrentTimeYYYY_MM_dd_HH_mm_ss(),
        'organId': getOrganId(),
        'organPath': getOrganPath(),
        'goodsName':"a",
        'status': status
      }
      this.listLoading = true
      manageStatus(goodsVO).then(response => {
        const gateway = response.data
        let data = gateway.data
        if (gateway.successful) {
        // this.fetchData()
        } else {
          this.$message({
            type: 'info',
            message: data.description || getSystemErrorCode(data.status)
          })
        }
        this.listLoading = false
      })
    }

  }
}

</script>
